<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Role;

class UnionPayController extends Controller{
	
	public function pay(){

	    $gateway = \Omnipay::gateway('unionpay');

	    $order = [
	        'orderId' => date('YmdHis'),
	        'txnTime' => date('YmdHis'),
	        'orderDesc' => 'My test order title', //订单名称
	        'txnAmt' => '100', //订单价格
	    ];

	    $response = $gateway->purchase($order)->send();
	    $response->redirect();
   }


  public function result(){

    $gateway = \Omnipay::gateway('unionpay');
    $response = $gateway->completePurchase(['request_params'=>$_REQUEST])->send();
    if ($response->isPaid()) {
        exit('支付成功！');
    }else{
        exit('支付失败！');
    }
}




}
